<script type="text/javascript"><!--//--><![CDATA[//><!--

	var grid_reload = function(){
		$('#datagrid').datagrid('reload', $('#fm_search').serializeObject());
	};

	$(document).ready(function() {
		// Setup Datagrid
		$('#datagrid').datagrid({  
			url:gs_path+'/'+controller+'/getdata', 
			queryParams: $('#fm_search').serializeObject(),
			height:340,
			pagination:true,
			columns:[[
				{ field : 'ck', checkbox:true, width: 40, align: 'center' },
				{ field : 'jenis', title : 'Jenis', width : 120, sortable:true },
				{ field : 'bandwidth', title : 'Bandwidth', width : 250, sortable:true },
				{ field : 'kode_customer', title : 'Kode', width : 100, sortable:true },
				{ field : 'nama_customer', title : 'Nama', width : 150, sortable:true },
				{ field : 'berhenti_berlangganan', title : '-', width : 250, sortable:true }
/*				{ field : 'kota', title : 'kota', width : 250, sortable:true },
				{ field : 'no_telp', title : 'no_telp', width : 250, sortable:true },
				{ field : 'no_hp', title : 'no_hp', width : 250, sortable:true },
				{ field : 'no_fax', title : 'no_fax', width : 250, sortable:true },
				{ field : 'email', title : 'email', width : 250, sortable:true },
				{ field : 'tagihan_nama', title : 'tagihan_nama', width : 250, sortable:true },
				{ field : 'tagihan_departemen', title : 'tagihan_departemen', width : 250, sortable:true },
				{ field : 'tagihan_alamat', title : 'tagihan_alamat', width : 250, sortable:true },
				{ field : 'tagihan_kode_pos', title : 'tagihan_kode_pos', width : 250, sortable:true },
				{ field : 'tagihan_telp', title : 'tagihan_telp', width : 250, sortable:true },
				{ field : 'tagihan_hp', title : 'tagihan_hp', width : 250, sortable:true },
				{ field : 'tagihan_fax', title : 'tagihan_fax', width : 250, sortable:true },
				{ field : 'tagihan_email', title : 'tagihan_email', width : 250, sortable:true }*/
			]]
		});		
		
		// Setup Form
		$('#form_master').setupForm([			
			{ name: 'jenis', type: 'text', size: 'medium', maxlength: 15, noempty:true },
			{ name: 'bandwidth', type: 'text', size: 'long', maxlength: 100, noempty:true },
			{ name: 'kode_customer', type: 'text', size: 'medium', maxlength: 40, noempty:true },			
			{ name: 'nama_customer', type: 'text', size: 'medium', maxlength: 40, noempty:true },
			{ name: 'alamat', type: 'text', size: 'long', maxlength: 50, noempty:true },
			{ name: 'kota', type: 'text', size: 'long', maxlength: 100, noempty:true },
			{ name: 'contact_person', type: 'text', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'no_telp', type: 'text', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'no_fax', type: 'text', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'no_hp', type: 'text', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'periode_tagihan', type: 'text', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'abodemen', type: 'text', size: 'long', maxlength: 40, noempty:true },
			{ name: 'total', type: 'text', size: 'long', maxlength: 40, noempty:true },
			{ name: 'ppn', type: 'text', size: 'long', maxlength: 100, noempty:true },
			{ name: 'terbilang', type: 'text', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'no_fpb', type: 'text', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'email', type: 'text', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'mulai_berlangganan', type: 'date', size: 'medium', maxlength: 30, noempty:true },
			{ name: 'due_date', type: 'text', size: 'long', maxlength: 40 },
			{ name: 'berhenti_berlangganan', type: 'date', size: 'medium', maxlength: 30, noempty:true }
			]);
		
		
		// Create Dialog
		$('#dialog_container').dialog({
			closed:true,
			modal:true,
			title: '_',
			width:600,
			buttons:[{
				text:'Save',
				iconCls:'icon-save',
				handler:function(){
					$('#form_master').submitForm('/'+controller+'/ajax_post', { onComplete : function(){ $('#dialog_container').dialog('close'); $('#datagrid').datagrid('reload'); }} );
				}
			},{
				text:'Close',
				iconCls:'icon-cancel',
				handler:function(){
					$('#dialog_container').dialog('close');
				}
			}]
		});
		
		
		// Set Action Button
		var buttons = [ { label: 'Add', icon: 'add', onclick: function() {
							resetError();
							$('#dialog_container').dialog('open');
							$('#form_master').data('mode', 'create');
							$('#form_master').parent().parent().parent().prev().find('.panel-title').html('New Customer');
							$('#kode_customer').readonly(false);
							//$('#kode_produk, #nama_produk, #harga, #keterangan').val('');
							$('#kode_customer').focus();
						} },
						{ label: 'Edit', icon: 'edit', onclick: function() {
							var oSel=$('#datagrid').datagrid('getSelected'); 
							if(oSel==null){ alert('Please select row!'); }
							else{ 
								resetError();
								$('#dialog_container').dialog('open'); 
								$('#form_master').data('mode', 'edit');
								$('#form_master').parent().parent().parent().prev().find('.panel-title').html('Edit Customer');
								$('#kode_customer').readonly();
								jsonToForm(oSel); $('#nama').focus();
							} 
						} },
						{label: 'Delete', icon: 'delete', onclick: function() { 
							var oSel = $('#datagrid').datagrid('getSelected'); 
							if (oSel == null) { 
								$.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
							} else { 
								deleteData(['kode_customer']);
							} 
						}}];
		setAction(buttons);
		
		
		$('#fm_search').focusFirst();
	});
//--><!]]></script>

<div id="tb" style="padding:5px;height:auto">
    <div>
        <form id="fm_search" onsubmit="grid_reload(); return false;">
        	<table class="tb_form" style="margin-bottom:0px">
            <tr>
            	<td width="100">Keyword</td>
                <td><input type="text" id="keyword" name="keyword" class="textfield medium" />
                	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload(); return false;">Search</a>
                </td>
            </tr>
            </table>
        </form>
    </div>
</div>
<div id="datagrid" toolbar="#tb"></div>
<?php
	$a = date('d-m-Y ');
	$b = 0;
	$c = 0;
		echo"$a $b$c:$b$c";
?>

<div id="dialog_container" style="padding:5px;width:600px;height:600px;">
	<form id="form_master">
    <table class="tb_form" style="width:100%;" cellpadding="0" cellspacing="0">
     <tr>
        <td class="label">Jenis</td>
        <td><input id="jenis" /></td>
    </tr>
     <tr>
        <td class="label">Bandwidth</td>
        <td><input id="bandwidth" /></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">Kode Customer</td>
        <td><input id="kode_customer" /></td>
    </tr>
    <tr>
        <td class="label">Nama</td>
        <td><input id="nama_customer" /></td>
    </tr>    
    <tr>
        <td class="label">Alamat</td>
        <td><input id="alamat" /></td>
    </tr>
    <tr>
        <td class="label">Kota</td>
        <td><input id="kota" /></td>
    </tr>    
    <tr>
        <td class="label">Kontak Person</td>
        <td><input id="contact_person" /></td>
    </tr>    
    <tr>
        <td class="label">Telephone</td>
        <td><input id="no_telp" /></td>
    </tr>    
    <tr>
        <td class="label">Fax</td>
        <td><input id="no_fax" /></td>
    </tr>   
    <tr>
        <td class="label">Handphone</td>
        <td><input id="no_hp" /></td>
    </tr>  
    <tr>
        <td class="label">Periode Tagihan</td>
        <td><input id="periode_tagihan" /></td>
    </tr>    
    <tr>
        <td class="label">Abodemen</td>
        <td><input id="abodemen" /></td>
    </tr>   
    <tr>
        <td class="label">Total</td>
        <td><input id="total" /></td>
    </tr>   
    <tr>
        <td class="label">PPN</td>
        <td><input id="ppn" /></td>
    </tr>  
    <tr>
        <td class="label">Terbilang</td>
        <td><input id="terbilang" /></td>
    </tr>   
    <tr>
        <td class="label">Nomor FPB</td>
        <td><input id="no_fpb" /></td>
    </tr>    
    <tr>
        <td class="label">Email</td>
        <td><input id="email" /></td>
    </tr>   
    <tr>
        <td class="label">Mulai Berlanggan</td>
        <td><input id="mulai_berlangganan" /></td>
    </tr>    
    <tr>
        <td class="label">Due Date</td>
        <td><input id="due_date" /></td>
    </tr>   
    <tr>
        <td class="label">Berhenti Berlanggan</td>
        <td><input id="berhenti_berlangganan" /></td>
    </tr>
    </table>
	</form>
</div>